<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>学习兴税</title>
    <link rel="stylesheet" href="../css/base.css" />
    <link rel="stylesheet" href="../css/animate.css" />
    <link rel="stylesheet" href="../css/style.css" />
    <script src="../js/jquery.js"></script>
    <script src="../js/common.js"></script>
  </head>
  <body>
    <div id="questionResult" class="comModal questionResult">
      <input class="hidden" type="text" />
      <div class="outsideBox">
        <div class="insideBox">
          <div class="resultInfo">
            <div class="numberInfo">
              <div class="number">
                <img src="../images/number.png" />
                <span class="text" id="scoreInfo">96</span>
              </div>
              <div class="text2">再接再厉</div>
              <!-- <div class="text3">
                <span>历史最高分：<blod>90分</blod></span>
                <span>同期排名：<blod>120名</blod></span>
              </div> -->
            </div>
            <div class="formBox">
              <div class="title">完善个人信息，查看答案</div>
              <div class="formInfo">
                <div class="items">
                  <div class="label">
                    <span class="red">* </span>
                    <span>姓名/昵称：</span>
                  </div>
                  <div class="input">
                    <input id="name" autocomplete="off" type="text" />
                  </div>
                </div>
                <div class="items">
                  <div class="label">
                    <span class="red">* </span>
                    <span>手机号码：</span>
                  </div>
                  <div class="input">
                    <input id="phone" autocomplete="off" type="text" />
                  </div>
                </div>
                <div class="items">
                  <div class="label">
                    <span>办税身份：</span>
                  </div>
                  <div class="input">
                    <select id="userTypeSelect" name="userType">
                      <option value="个人">个人</option>
                      <option value="企业法人">企业法人</option>
                      <option value="财务">财务</option>
                    </select>
                  </div>
                </div>
              </div>
            </div>
            <div class="btnBox">
              <div class="prevBtn" onclick="backHome()">回主页</div>
              <div class="submitBtn" onclick="submitInfo()">提交</div>
              <div class="errorBtn hidden" onclick="errorPage()">错题回顾</div>
              <div class="errorBtn hidden" onclick="exportFile()">导出</div>
            </div>
          </div>
          <div class="rightInfo">
            <div class="today">2023年07月21日</div>
            <div class="title blod">专题学习：</div>
            <div class="subInfo">
              <div class="learnTitle" id="ztTitle">《个人所得税汇算》</div>
              <div class="content" id="ztContent">
                个人所得税汇算,个人所得税汇算,个人所得税汇算，个人所得税汇算，个人所得税汇算，个人所得税汇算，个人所得税汇算，个人所得税汇算
              </div>
            </div>
            <div style="position:absolute;bottom:0;left:0;">
              <div class="title">专题学习二维码：</div>
            <div class="qr">
              <img id="mark" src="../images/qrcode.png" />
            </div>
            <div class="title">纳税人学习热线：</div>
            <div class="blue" id="phoneInfo">05672260819</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
  <script>
    $(function () {
      var resData = JSON.parse(localStorage.getItem("resData"));
      $("#scoreInfo").text(resData.score)
      getDate()
      getDetail();
      setWindow();
    });
    //导出
    function exportFile(){
      var url = '/topic/api/open/exam/export?tdId='+localStorage.getItem('tdId')
      window.open(url)
      // ajaxRequest({
      //   type: "GET",
      //   url: "/open/exam/export?tdId="+localStorage.getItem('tdId'),
      //   success: function (res) {
      //     console.log('导出成功')
      //   },
      //   error: function (error) {
      //     console.log('导出失败')
      //   },
      // });
    }
     //日期
    function getDate(){
      var date = new Date();
      var year = date.getFullYear()
      var month = date.getMonth()+1;
      var day = date.getDate();
      month = month<10?'0'+month:month;
      day= day<10?'0'+day:day;
      var _date= year+'年'+month+'月'+day+'日';
      $(".today").text(_date);
    }
    function getDetail() {
      ajaxRequest({
        type: "GET",
        url: "/open/exam/getConfig?cfgKey=yw.open.exam.copy.title",
        success: function (res) {
          $("#ztTitle").text(res.data);
        },
        error: function (error) {},
      });
      ajaxRequest({
        type: "GET",
        url: "/open/exam/getConfig?cfgKey=yw.open.exam.copy",
        success: function (res) {
          $("#ztContent").text(res.data);
        },
        error: function (error) {},
      });
      ajaxRequest({
        type: "GET",
        url: "/open/exam/getConfig?cfgKey=yw.open.exam.qrCode",
        success: function (res) {
          $("#mark").attr('src',res.data);
        },
        error: function (error) {},
      });
      ajaxRequest({
        type: "GET",
        url: "/open/exam/getConfig?cfgKey=yw.open.exam.hotLine",
        success: function (res) {
          var arr = (res.data||'').split(',')
          $("#phoneInfo").html(arr.join('<br/>'));
        },
        error: function (error) {},
      });
    }
    function submitInfo() {
      var name = $("#name").val();
      var phone = $("#phone").val();
      if (!name) {
        return alert("请输入姓名！");
      }
      var reg =
        /^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\d{8}$/;
      if (!phone) {
        return alert("请输入手机号码！");
      } else if (!reg.test(phone)) {
        return alert("请输入正确的手机号码！");
      }
      var taxIdentity=$("#userTypeSelect").val()
      ajaxRequest({
        type: "POST",
        url: "/open/exam/submitUserInfo?tdId="+localStorage.getItem('tdId')+'&name='+name+'&phone='+phone+'&taxIdentity='+taxIdentity,
        success: function (res) {
          var _data = res.data||{};//排名及积分信息
          $(".submitBtn").addClass("hidden");
          $(".errorBtn").removeClass("hidden");
          $("#name,#phone,#userTypeSelect").attr('disabled');
          // alert('提交成功！')
        },
        error: function (error) {},
      });
     
    }
    function backHome() {
      location.href = "/html/index.html";
    }
    function errorPage() {
      location.href = "/html/questionError.html";
    }
  </script>
</html>
